class Solution
{
public:
    int maximumLength(vector<int> &nums)
    {
        int l1 = 0;
        int l2 = 0;
        int cur = 0;
        for (int num : nums)
        {
            if ((num & 1) == cur)
            {
                ++l1;
                cur = !cur;
            }
        }
        cur = 1;
        for (int num : nums)
        {
            if ((num & 1) == cur)
            {
                ++l2;
                cur = !cur;
            }
        }
        int l3 = 0;
        int l4 = 0;
        for (int num : nums)
        {
            if (num & 1)
            {
                ++l3;
            }
            else
            {
                ++l4;
            }
        }
        return max({l1, l2, l3, l4});
    }
};